//
//  Section.m
//  
//  jhf
//
//  Created by 计海峰 on 2019/6/28.
//  Copyright © 2019 计海峰. All rights reserved.
//

#import "Section.h"

@implementation Section

//MARK: - method
- (instancetype)init
{
    self = [super init];
    if (self) {
        [self setup];
    }
    return self;
}

- (void)setup {
    @weakify(self)
    [[[self.rows changeSignal] throttle:0.3] subscribeNext:^(id  _Nullable x) {
        @strongify(self)
        [self.reloadSubject sendNext:x]; 
    }];
}

+ (instancetype)sectionWithRows:(NSMutableArray <Row *>*)array; {
    Section *sec = [[Section alloc] init];
    [sec.rows addObjectsFromArray:array];
    return sec;
}


//MARK: - 懒加载
- (RACSubject *)reloadSubject {
    if (!_reloadSubject) {
        _reloadSubject = [RACSubject subject];
    }
    return _reloadSubject;
}

- (KVOMutableArray <Row *>*)rows {
    if (!_rows) {
        _rows = [KVOMutableArray array];
    }
    return _rows;
}

@end
